package com.innovations.inn.service.impl;

import java.util.List;

import com.innovations.common.utils.uuid.IdGeneratorSnowflake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.innovations.inn.mapper.ResearchOutcomesReviewsMapper;
import com.innovations.inn.domain.ResearchOutcomesReviews;
import com.innovations.inn.service.IResearchOutcomesReviewsService;

/**
 * 科研成果评价Service业务层处理
 * 
 * @author dp
 * @date 2024-08-09
 */
@Service
public class ResearchOutcomesReviewsServiceImpl implements IResearchOutcomesReviewsService 
{
    @Autowired
    private ResearchOutcomesReviewsMapper researchOutcomesReviewsMapper;
    @Autowired
    IdGeneratorSnowflake idGeneratorSnowflake;

    /**
     * 查询科研成果评价
     * 
     * @param reviewsId 科研成果评价主键
     * @return 科研成果评价
     */
    @Override
    public ResearchOutcomesReviews selectResearchOutcomesReviewsByReviewsId(Long reviewsId)
    {
        return researchOutcomesReviewsMapper.selectResearchOutcomesReviewsByReviewsId(reviewsId);
    }

    /**
     * 查询科研成果评价列表
     * 
     * @param researchOutcomesReviews 科研成果评价
     * @return 科研成果评价
     */
    @Override
    public List<ResearchOutcomesReviews> selectResearchOutcomesReviewsList(ResearchOutcomesReviews researchOutcomesReviews)
    {
        return researchOutcomesReviewsMapper.selectResearchOutcomesReviewsList(researchOutcomesReviews);
    }

    /**
     * 新增科研成果评价
     * 
     * @param researchOutcomesReviews 科研成果评价
     * @return 结果
     */
    @Override
    public int insertResearchOutcomesReviews(ResearchOutcomesReviews researchOutcomesReviews)
    {
        return researchOutcomesReviewsMapper.insertResearchOutcomesReviews(researchOutcomesReviews);
    }

    /**
     * 修改科研成果评价
     * 
     * @param researchOutcomesReviews 科研成果评价
     * @return 结果
     */
    @Override
    public int updateResearchOutcomesReviews(ResearchOutcomesReviews researchOutcomesReviews)
    {
        return researchOutcomesReviewsMapper.updateResearchOutcomesReviews(researchOutcomesReviews);
    }

    /**
     * 批量删除科研成果评价
     * 
     * @param reviewsIds 需要删除的科研成果评价主键
     * @return 结果
     */
    @Override
    public int deleteResearchOutcomesReviewsByReviewsIds(Long[] reviewsIds)
    {
        return researchOutcomesReviewsMapper.deleteResearchOutcomesReviewsByReviewsIds(reviewsIds);
    }

    /**
     * 删除科研成果评价信息
     * 
     * @param reviewsId 科研成果评价主键
     * @return 结果
     */
    @Override
    public int deleteResearchOutcomesReviewsByReviewsId(Long reviewsId)
    {
        return researchOutcomesReviewsMapper.deleteResearchOutcomesReviewsByReviewsId(reviewsId);
    }

    /**
     * 实体数据补全
     *
     * @param researchOutcomesReviews 实体
     * @param userId       用户id
     * @param crateType    创建类型 1：新增 2：修改
     */
    @Override
    public void completeData(ResearchOutcomesReviews researchOutcomesReviews, Long userId, Integer crateType) {
        //主键集合键
        if (researchOutcomesReviews.getReviewsId() == null || "".equals(researchOutcomesReviews.getReviewsId())) {
            researchOutcomesReviews.setReviewsId(idGeneratorSnowflake.nextId());
        }
//        //创建人、创建时间
//        if (crateType == 1) {
//            if (researchOutcomesReviews.getCreateBy() == null || "".equals(researchOutcomesReviews.getCreateBy())) {
//                researchOutcomesReviews.setCreateBy(userId);
//            }
//            if (researchOutcomesReviews.getCreateTime() == null) {
//                researchOutcomesReviews.setCreateTime(DateUtils.getNowDate());
//            }
//        }
//        //修改人
//        if (researchOutcomesReviews.getModifyBy() == null) {
//            researchOutcomesReviews.setModifyBy(userId);
//        }
//        //修改时间
//        if (researchOutcomesReviews.getModifyTime() == null) {
//            researchOutcomesReviews.setModifyTime(DateUtils.getNowDate());
//        }
    }
}
